home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT52.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.2 KB  |  81 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 52                         
  5.                                           
  6.   A full FLI/FLC animation player. Allows filenames with wildcards and a      
  7.   selection of memory or disk playback. Resolution of the animation is
  8.   assumed to be 320x200 max (although you could assign flicscreen to a large
  9.   virtual screen buffer to handle bigger resolutions).
  10.                                           
  11.   *** PROJECT ***                                                             
  12.   This program requires the WGT5_WC.LIB and WFLIC_WC.LIB files to be linked.  
  13.                                           
  14.   *** DATA FILES ***                                                          
  15.   Any FLI or FLC file (or files).                                             
  16.                                WATCOM C++ VERSION 
  17. ==============================================================================
  18. */
  19.  
  20. #include <dos.h>
  21. #include <stdlib.h>
  22. #include <wgt5.h>
  23. #include <wgtflic.h>
  24.  
  25. #define ESC             27              /* ESCAPE KEY */
  26.  
  27. char         ch;                        /* Keyboard input */
  28. int          playmode;                  /* Memory or disk playback */
  29. int          filefound;                 /* 1 if the animation file was found */
  30. int          oldmode;                   /* Previous video mode */
  31. int          status;                    /* Status of FLI/FLC */
  32. int          flic_mode;
  33.  
  34. void main (int argc, char *argv[])
  35. {
  36.   unsigned totl;
  37.  
  38.   if ((argc < 2) || (argc > 3))         /* Display how to use this program */
  39.   {
  40.     printf ("\nWGT52 - Plays FLI and FLC files from either memory or disk\n");
  41.     printf ("USAGE:   WGT52 filename [play_mode]\n");
  42.     printf ("playmode can be:\n");
  43.     printf (" 0 - Play from disk (default)\n");
  44.     printf (" 1 - Play from memory\n");
  45.     printf ("\nPress any key\n");
  46.     getch ();
  47.     exit (1);
  48.   }
  49.  
  50.   if (argc > 2)
  51.     flic_mode = atoi (argv[2]);         /* Get playmode from command line */
  52.   else flic_mode = FLIC_DISK;           /* Or default to disk */
  53.   
  54.   if (flic_mode > 1)
  55.     flic_mode = FLIC_DISK;
  56.  
  57.  
  58.   oldmode = wgetmode ();                /* Preserve initial video mode */
  59.   vga256 ();                            /* Go to graphics mode */
  60.   flicscreen = abuf;                    /* Set to visual screen */
  61.                     /* You must set this AFTER vga256(); */
  62.   
  63.   if (openflic (argv[1], flic_mode, 1) == FLIC_OK) /* See if we opened file ok */
  64.     do {
  65.       status = nextframe ();                  /* Show frame of animation */
  66.       if ((status != FLIC_OK) && (status != FLIC_DONE))
  67.     break;                                /* Abort if error */
  68.       delay (flichdr.speed);                  /* Delay proper amount */
  69.     } while (!kbhit ());                      /* Continue until keypress */
  70.  
  71.   /* NOTE: If you don't want the flic to loop, remove the check for
  72.        FLIC_DONE. This will abort playback when the animation is done */
  73.  
  74.   while (kbhit())                             /* Get key from buffer */
  75.     ch = getch ();
  76.  
  77.   closeflic ();                               /* Close current animation */
  78.  
  79.   wsetmode (oldmode);                           /* and video mode */
  80. }
  81.